package morphing;



import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;

import java.util.ArrayList;
import java.util.Iterator;


public class InterpolacaoVetorial {
	private int transicoes;
	
	public InterpolacaoVetorial(int transicoes){
		this.transicoes = transicoes;
	}
	
	public ArrayList<Line2D.Double> geraInterpolacao(int indice,ArrayList<Line2D.Double> vetores1, ArrayList<Line2D.Double> vetores2) {
		
		Line2D.Double line1,line2;
		ArrayList<Line2D.Double> list = new ArrayList<Line2D.Double>();
		float t;
		float fator = 1 / (float) transicoes;
		
		Iterator iter1 = vetores1.iterator();
		Iterator iter2 = vetores2.iterator();
		
		t=fator*indice;
		while(iter1.hasNext()){
			line1 = (Line2D.Double) iter1.next();
			line2 = (Line2D.Double) iter2.next();
			list.add(new Line2D.Double(line1.x1*(1-t) + line2.x1*t,
									   line1.y1*(1-t) + line2.y1*t,
									   line1.x2*(1-t) + line2.x2*t,
									   line1.y2*(1-t) + line2.y2*t));
		}

		return list;
	}
	
	public ArrayList<Line2D.Double>[] geraInterpolacoes(ArrayList<Line2D.Double> vetores1,ArrayList<Line2D.Double> vetores2, BufferedImage img1,BufferedImage img2){
		
		
		
		
		
		ArrayList<Line2D.Double>[] arrei = new ArrayList[transicoes-1];
		for(int cont =1 ; cont < transicoes; cont++){
			arrei[cont-1] = geraInterpolacao(cont,vetores1,vetores2);
		}
		return arrei;
	}
	
	
	
	
	
}
